<?php
namespace app\index\model;
use think\Model;
use think\Paginator;
use think\Db;
	class Books extends Model
	{
		protected $connection=[
			'type'            => 'mysql',
			// 服务器地址
			'hostname'        => '127.0.0.1',
			// 数据库名
			'database'        => 'Book',
			// 用户名
			'username'        => 'root',
			// 密码
			'password'        => '123456',
			// 端口
			'hostport'        => '3306',
			// 连接dsn
			'dsn'             => '',
			// 数据库连接参数
			'params'          => [],
			// 数据库编码默认采用utf8
			'charset'         => 'utf8',
			// 是否严格检查字段是否存在
			'fields_strict'   => true,
			// 数据集返回类型
			'resultset_type'  => 'array'
		];
		public function index(){
			$date=$this->where("leixing",'001')->paginate(2);
			return $date;
		}
		public function api(){
			$date["a"]=$this->field("name,zuozhe")->limit(5)->select();
			
			return $date;
		}
		public function page(){
			
			$a=$this->field('name,zuozhe')->page('1,10')->select();
			return $a;
		}
		//搜索
		public function sou(){
			$data=$this->field("name,zuozhe")->select();
			return $data;
		}
		public function lei(){
			$data['city']=$this->where(array('leixing'=>'001'))->count();
			$data['military']=$this->where(array('leixing'=>'002'))->count();
			$data['history']=$this->where(array('leixing'=>'003'))->count();
			$data['queer']=$this->where(array('leixing'=>'004'))->count();
			$data['emprise']=$this->where(array('leixing'=>'005'))->count();
			$data['xianxia']=$this->where(array('leixing'=>'006'))->count();
			$data['actuality']=$this->where(array('leixing'=>'007'))->count();
			$data['fantasy']=$this->where(array('leixing'=>'008'))->count();
			return $data;
		}
		
	}